package com.sora.commonutils.exceptionhandler;

import com.sora.commonutils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Classname: Globalexceptionhandler
 * @Description:
 * @Author: Stonffe
 * @Date: 2023/1/6 10:12
 */
@Slf4j
@ControllerAdvice
public class Globalexceptionhandler {
    @ExceptionHandler(GuliException.class)
    @ResponseBody
    public R error(GuliException e) {
        log.error(e.getMessage());
        e.printStackTrace();
        return R.error().code(e.getCode()).message(e.getMsg());
    }
}
